home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / curs_set.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  3KB  |  110 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #include <defs.h>
  5. #include <term.h>
  6. #endif
  7. #undef curs_set
  8.  
  9. #ifdef PDCDEBUG
  10. char *rcsid_curs_set = "$Header: C:\CURSES\portable\RCS\curs_set.c 2.1 1993/06/18 20:19:11 MH Rel MH $";
  11. #endif
  12.  
  13.  
  14. /*man-start*********************************************************************
  15.  
  16.   curs_set()    - set visibility of cursor.
  17.  
  18.   X/Open Description:
  19.      This routine is used to set the visibility of the cursor. The cursor
  20.      can be made invisible, normal or highly visible by setting the
  21.      parameter to 0, 1 or 2 respectively. If an invalid value is passed
  22.      the function will set the cursor to "normal".
  23.  
  24.   X/Open Return Value:
  25.      curs_set returns the previous visibility value.
  26.  
  27.   X/Open Errors:
  28.      No errors are defined for this function.
  29.  
  30.   Portability:
  31.      PDCurses    int curs_set( int visibility );
  32.      SYS V Curses    int curs_set( int visibility );
  33.  
  34. **man-end**********************************************************************/
  35.  
  36. int    curs_set(int visibility)
  37. {
  38. #ifdef OS2
  39.  VIOCURSORINFO pvioCursorInfo;
  40. #endif
  41.  int start,end,hidden=0;
  42.  static int old_vis=1;
  43.  int ret_vis;
  44.  
  45. #ifdef PDCDEBUG
  46.     if (trace_on) PDC_debug("curs_set() - called: visibility=%d\n",visibility);
  47. #endif
  48.  
  49.     ret_vis = old_vis;
  50.     old_vis = visibility;
  51. #ifdef UNIX
  52.     switch(visibility)
  53.     {
  54.         case 0:  /* invisible */
  55.             if (cursor_invisible != NULL)
  56.                 putp(cursor_invisible);
  57.             break;
  58.         case 2:  /* highly visible */
  59.             if (cursor_visible != NULL)
  60.                 putp(cursor_visible);
  61.             break;
  62.         default:  /* normal visibility */
  63.             if (cursor_visible != NULL)
  64.                 putp(cursor_visible);
  65.             break;
  66.     }
  67.     return(OK);
  68. #else
  69.  
  70.     switch(visibility)
  71.     {
  72.         case 0:  /* invisible */
  73. #ifdef OS2
  74.             start = _cursvar.font / 4;
  75.             end = _cursvar.font;
  76. #else
  77.             start = 32;
  78.             end = 33;
  79. #endif
  80.             hidden = (-1);
  81.             break;
  82.         case 2:  /* highly visible */
  83.             start = 2;   /* almost full-height block */
  84.             end = _cursvar.font-1;
  85.             break;
  86.         default:  /* normal visibility */
  87.             start = _cursvar.font - 4;
  88.             end = _cursvar.font-1;
  89.             break;
  90.     }
  91.  
  92. #ifdef OS2
  93.     pvioCursorInfo.yStart = (USHORT)start;
  94.     pvioCursorInfo.cEnd = (USHORT)end;
  95.     pvioCursorInfo.cx = (USHORT)1;
  96.     pvioCursorInfo.attr = hidden;
  97.     VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo,0);
  98. #endif
  99.  
  100. #ifdef DOS
  101.     regs.h.ah = 0x01;
  102.     regs.h.al = (unsigned char)_cursvar.scrnmode;  /* if not set, some BIOSes hang */
  103.     regs.h.ch = (unsigned char)start;
  104.     regs.h.cl = (unsigned char)end;
  105.     int86(0x10, ®s, ®s);
  106. #endif
  107.     return( ret_vis );
  108. #endif
  109. }
  110.